package cn.iocoder.yudao.module.reading.controller.app.bookset.vo;

import cn.iocoder.yudao.module.reading.controller.app.book.vo.PictureBookRespVO;
import cn.iocoder.yudao.module.reading.framework.vo.BaseUrlConvertVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 绘本集详情 Response VO
 *
 * @author 芋道源码
 */
@Schema(description = "用户 APP - 绘本集详情 Response VO")
@Data
@EqualsAndHashCode(callSuper = false)
public class BookSetDetailRespVO extends BaseUrlConvertVO {

    @Schema(description = "绘本集ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long id;

    @Schema(description = "绘本集标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "牛津树1级")
    private String title;

    @Schema(description = "封面图片URL", example = "https://example.com/cover.jpg")
    private String cover;

    @Schema(description = "绘本集描述", example = "适合初学者的英文绘本")
    private String description;

    @Schema(description = "分类ID", example = "1")
    private Long categoryId;

    @Schema(description = "适龄范围", example = "3-6岁")
    private String ageRange;

    @Schema(description = "绘本数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
    private Integer bookCount;

    @Schema(description = "来源标签", example = "经典绘本")
    private String source;

    @Schema(description = "难度级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "beginner")
    private String difficultyLevel;

    @Schema(description = "语言类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "english")
    private String language;

    @Schema(description = "是否推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
    private Boolean isRecommended;

    @Schema(description = "绘本列表")
    private List<PictureBookRespVO> books;

    /**
     * 转换URL字段
     * 将相对路径转换为完整URL
     */
    @Override
    public void convertUrls() {
        this.cover = convertUrl(this.cover);

        // 转换绘本列表中的URL
        if (this.books != null) {
            this.books.forEach(PictureBookRespVO::convertUrls);
        }
    }
}
